<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<?php $this->load->view('head'); ?>
	<script>
		$(document).ready(function() {
			$('a').click(function () {
				if ((jQuery(this).attr("title") == "Deny!") 
					|| (jQuery(this).attr("title") =='Cancel this job order')
					|| (jQuery(this).attr("title") =='Delete this job order')){
						var link = jQuery(this).attr("href");
						var sub = link.split('/');
						var id = sub[sub.length-1];
						return confirm('Are you sure you want to remove #' + id + '?');
					}				
			});   
		});		  
	</script>
</head>

<body>

<script type="text/javascript">
var site_url = "http://bookabus.sg/";
$(document).ready(function(){
	
  //hide toolbar and make visible the 'show' button
	$("span.downarr a").click(function() {
    $("#toolbar").slideToggle("fast");
    $("#toolbarbut").fadeIn("slow");    
  });
  
  //show toolbar and hide the 'show' button
  $("span.showbar a").click(function() {
    $("#toolbar").slideToggle("fast");
    $("#toolbarbut").fadeOut();    
  });
  
  //show tooltip when the mouse is moved over a list element 
  $("ul#social li").hover(function() {
		$(this).find("div").fadeIn("fast").show(); //add 'show()'' for IE
    $(this).mouseleave(function () { //hide tooltip when the mouse moves off of the element
        $(this).find("div").hide();
    });
  });
  
  //don't jump to #id link anchor 
  $(".facebook, .twitter, .delicious, .digg, .rss, .stumble, .menutit, span.downarr a, span.showbar a").click(function() {
   return false;                                         
	});
	
  //show quick menu on click 
	$("span.menu_title a").click(function() {
		if($(".quickmenu").is(':hidden')){ //if quick menu isn't visible 
			$(".quickmenu").fadeIn("fast"); //show menu on click
		}
		else if ($(".quickmenu").is(':visible')) { //if quick menu is visible 
      $(".quickmenu").fadeOut("fast"); //hide menu on click
    }
	});
	
	//hide menu on casual click on the page
	$(document).click(function() {
			$(".quickmenu").fadeOut("fast");
			$(".quickmenu").css({'vivibility': 'hidden'});
	});
	$('.quickmenu').click(function(event) { 
		event.stopPropagation(); //use .stopPropagation() method to avoid the closing of quick menu panel clicking on its elements 
	});

		
});
	function jobaction(radioObj) {
		var flag = true;
		var radioLength = radioObj.length;
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				flag = false;
				window.location = site_url+"joborder/"+radioObj[i].value.substring(10,13)+"#actionForm";
			}
		}
		if(flag){
			alert("please choose a job for this action");
		}
	}
	function deletejob(radioObj) {
		var flag = true;
		var radioLength = radioObj.length;
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				flag = false;
				var a = confirm("Do you want to delete this job ?");
				if(a ){
					window.location = site_url+"joborder/admdelete/"+radioObj[i].value.substring(10,13);
				}
			}
		}
		if(flag){
			alert("please choose a job for this action");
		}
	}
	function denyquotation(radioObj) {
		var flag = true;
		var radioLength = radioObj.length;
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				flag = false;
				var a = confirm("Do you want to deny this quotation ?");
				if(a ){
					var reason = prompt("Reason :","");
					window.location = site_url+"joborder/deny/"+radioObj[i].value.substring(10,13)+"?reason="+reason;
					
				}
			}
		}
		if(flag){
			alert("please choose a job for this action");
		}
	}
	function reusejob(radioObj) {
		var flag = true;
		var radioLength = radioObj.length;
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				flag = false;
				window.location = site_url+"joborder/reuse/"+radioObj[i].value.substring(10,13);
			}
		}
		if(flag){
			alert("please choose a job for this action");
		}
	}
	function payment(radioObj) {
		var flag = true;
		var radioLength = radioObj.length;
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				flag = false;
				var purpose = prompt("Purpose of this payment: ","");
				window.location = site_url+"joborder/payment/"+radioObj[i].value.substring(10,13)+"?purpose="+purpose;
			}
		}
		if(flag){
			alert("please choose a job for this action");
		}
	}
	function editjob(radioObj) {
		var flag = true;
		var radioLength = radioObj.length;
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				flag = false;
				window.location = site_url+"request/time-based/0/"+radioObj[i].value.substring(10,13);
			}
		}
		if(flag){
			alert("please choose a job for this action");
		}
	}
	function receivepayment(radioObj) {
		var flag = true;
		var radioLength = radioObj.length;
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				flag = false;
				window.location = site_url+"joborder/receive_payment/"+radioObj[i].value.substring(10,13);
			}
		}
		if(flag){
			alert("please choose a job for this action");
		}
	}
	function SortJobIdUpOncoming(){
		window.location = site_url+"sort_job_id_up_oncoming";
	}
	function SortJobIdDownOncoming(){
		window.location = site_url+"sort_job_id_down_oncoming";
	}
	function SortDetailsUpOncoming(){
		window.location = site_url+"sort_details_up_oncoming";
	}
	function SortDetailsDownOncoming(){
		window.location = site_url+"sort_details_down_oncoming";
	}
	function SortJobIdUpCancel(){
		window.location = site_url+"sort_job_id_up_cancel";
	}
	function SortJobIdDownCancel(){
		window.location = site_url+"sort_job_id_down_cancel";
	}
	function SortDetailsUpCancel(){
		window.location = site_url+"sort_details_up_cancel";
	}
	function SortDetailsDownCancel(){
		window.location = site_url+"sort_details_down_cancel";
	}
	function SortJobIdUpComplete(){
		window.location = site_url+"sort_job_id_up_complete";
	}
	function SortJobIdDownComplete(){
		window.location = site_url+"sort_job_id_down_complete";
	}
	function SortDetailsUpComplete(){
		window.location = site_url+"sort_details_up_complete";
	}
	function SortDetailsDownComplete(){
		window.location = site_url+"sort_details_down_complete";
	}
	function SortJobIdUpPaymentDue(){
		window.location = site_url+"sort_job_id_up_payment_due";
	}
	function SortJobIdDownPaymentDue(){
		window.location = site_url+"sort_job_id_down_payment_due";
	}
	function SortDetailsUpPaymentDue(){
		window.location = site_url+"sort_details_up_payment_due";
	}
	function SortDetailsDownPaymentDue(){
		window.location = site_url+"sort_details_down_payment_due";
	}
	function SortJobIdUpAwaitingConfirm(){
		window.location = site_url+"sort_job_id_up_awaiting_confirm";
	}
	function SortJobIdDownAwaitingConfirm(){
		window.location = site_url+"sort_job_id_down_awaiting_confirm";
	}
	function SortDetailsUpAwaitingConfirm(){
		window.location = site_url+"sort_details_up_awaiting_confirm";
	}
	function SortDetailsDownAwaitingConfirm(){
		window.location = site_url+"sort_details_down_awaiting_confirm";
	}
	function SortJobIdUpAwaitingQuote(){
		window.location = site_url+"sort_job_id_up_awaiting_quote";
	}
	function SortJobIdDownAwaitingQuote(){
		window.location = site_url+"sort_job_id_down_awaiting_quote";
	}
	function SortDetailsUpAwaitingQuote(){
		window.location = site_url+"sort_details_up_awaiting_quote";
	}
	function SortDetailsDownAwaitingQuote(){
		window.location = site_url+"sort_details_down_awaiting_quote";
	}
	function runScript(e,s,n,i,num,numpages) {
		if (e.keyCode == 13) {
				
				if( n == 4){
					if((document.getElementById('page4').value < 1) || (document.getElementById('page4').value > numpages)){
						alert("The number of page is not available at a moment. Please try with another number");
						document.getElementById('page4').value = '';
					}
					else{
						var page = document.getElementById('page4').value;
						page = page-1;
						loadJobPage(s, n, page, i ,num);
						document.getElementById('cancel').scrollIntoView(true);
					}
				}
				else if( n == 5){
					if((document.getElementById('page5').value < 1) || (document.getElementById('page5').value > numpages)){
						alert("The number of page is not available at a moment. Please try with another number");
						document.getElementById('page5').value = '';
					}
					else{
						var page = document.getElementById('page5').value;
						page = page-1;
						loadJobPage(s, n, page, i ,num);
						document.getElementById('need_quote').scrollIntoView(true);
					}
				}
				else if( n == 6){
					if((document.getElementById('page6').value < 1) || (document.getElementById('page6').value > numpages)){
						alert("The number of page is not available at a moment. Please try with another number");
						document.getElementById('page6').value = '';
					}
					else{
						var page = document.getElementById('page6').value;
						page = page-1;
						loadJobPage(s, n, page, i ,num);
						document.getElementById('need_confirm').scrollIntoView(true);
					}
				}
				else if( n == 3){
					if((document.getElementById('page3').value < 1) || (document.getElementById('page3').value > numpages)){
						alert("The number of page is not available at a moment. Please try with another number");
						document.getElementById('page3').value = '';
					}
					else{
						var page = document.getElementById('page3').value;
						page = page-1;
						loadJobPage(s, n, page, i ,num);
						document.getElementById('complete').scrollIntoView(true);
						}
				}
				else if( n == 2){
					if((document.getElementById('page2').value < 1) || (document.getElementById('page2').value > numpages)){
						alert("The number of page is not available at a moment. Please try with another number");
						document.getElementById('page2').value = '';
					}
					else{
						var page = document.getElementById('page2').value;
						page = page-1;
						loadJobPage(s, n, page, i ,num);
						document.getElementById('payment_due').scrollIntoView(true);
					}
				}
				else if( n == 0){
					if((document.getElementById('page0').value < 1) || (document.getElementById('page0').value > numpages)){
						alert("The number of page is not available at a moment. Please try with another number");
						document.getElementById('page0').value = '';
					}
					else{
						var page = document.getElementById('page0').value;
						page = page-1;
						loadJobPage(s, n, page, i ,num);
						document.getElementById('oncoming').scrollIntoView(true);
						}
				}
			
		}
	}
	
</script>
<div id="toolbarbut"> <!-- hide button -->
<span class="showbar"><a href="#">show bar</a></span>
</div>

<div id="toolbar"> <!-- toolbar container -->

<div class="leftside"> <!-- all things in floating left side -->
  <ul id="social"><center><strong>
    <li><a class="taskbar_tool" onclick="jobaction(document.getElementsByName('group1'));"> Edit Price</a><!-- icon -->
    </li>
	<li><a class="taskbar_tool" onclick="jobaction(document.getElementsByName('group1'));"> New Message</a><!-- icon -->
    </li>
	<li><a class="taskbar_tool" onclick="editjob(document.getElementsByName('group1'));" > Edit Job</a><!-- icon -->
    </li>
	<li><a class="taskbar_tool" onclick="receivepayment(document.getElementsByName('group1'));" > Receive Payment</a><!-- icon -->
    </li>
	<li><a class="taskbar_tool" onclick="denyquotation(document.getElementsByName('group1'));"> Deny Quotation</a><!-- icon -->
    </li>
	<li><a class="taskbar_tool" onclick="deletejob(document.getElementsByName('group1'));"> Delete Job</a><!-- icon -->
    </li>
	<li><a class="taskbar_tool" onclick="payment(document.getElementsByName('group1'));"> Request Payment</a><!-- icon -->
    </li>
	<li><a class="taskbar_tool" onclick="reusejob(document.getElementsByName('group1'));"> Reuse Job</a><!-- icon -->
    </li>
	</strong>
    </center>
  </ul>
</div>

<div class="rightside"> <!-- all things in floating left side -->
  <span class="downarr"> <!-- hide button -->
  <a href="#"></a>
  </span>
  
</div>

</div>



	<?php $this->load->view('header_admin.php'); ?>
	<!-- Content Area -->
	<div class="wrapper-world content">
		<div class="wrapper">
			<form class="standard-form" onsubmit="jQuery('#jobSearch').change(); return false;">
				<div class="type-text"><input type="text" id="jobSearch" value="Search job orders by User,ID,Address..."/></div>
			</form>
			
				
			<form class="standard-form" onsubmit="jQuery('#jobSearch2').change(); return false;">
				<div class="type-text"><input type="text" name="jobSearch2" id="jobSearch2" value="Search job orders by Date..."/></div>
				<script type="text/javascript">
					AnyTime.picker( "jobSearch2",
						{ format: "%z-%m-%d", firstDOW: 1, earliest: new Date() } );
				</script>
			</form>
			<form class="standard-form1" >
				<div class="type-text"><a href=""><input type="button" id="reset" value="Refresh"/></a></div>
			</form>
			<div class="clr"></div>
		</div>
		
		<h1><a id="oncoming">Oncoming </a><span class="quantity"><?php echo $oncomingCount; ?></span></h1>
		<div class="job-listing">
			<div class="wrapper-world"> <!-- zaglaviq -->
				<div class="wrapper">
					<div class="job-id">Job ID <span class="uparrs"><a onclick="SortJobIdUpOncoming();"></a></span><span class="downarrs"><a onclick="SortJobIdDownOncoming();"></a></span></div>
					<div class="job-details">Details <span class="uparrs"><a onclick="SortDetailsUpOncoming();"></a></span><span class="downarrs"><a onclick="SortDetailsDownOncoming();"></a></span></div>
					<div class="job-user">User</div>
					<div class="job-status">Status </div>
					<div class="job-price">Price</div>
					<div class="job-action">Pick</div>
					<div class="clr"></div>
				</div>
			</div>
			
			<div class="jobsContainer">
				<?php $c=0; foreach ($oncoming as $jobOrder):
					$job = $jobOrder['order'];
					$routes = $jobOrder['routes'];
					$juinfo = $jobOrder['userinfo'];
				?>
				<div class="wrapper-world job-<?php echo (($c%2 == 0) ? "odd" : "even"); if ($job->madmin == 1) { echo "  job-orange"; } ?>">
					<div class="wrapper">
						<div class="job-id"><a href="joborder/<?php echo (substr($this->Jobs->getID($job),10,3)); ?>"><?php echo $this->Jobs->getID($job); ?></a></div>
						<div class="job-details">
							<?php $c1 = 0; foreach ($routes as $route): ?>
								<?php if ($c1 > 0): ?><br /><?php else: $c1++; endif; ?>
								<?php echo nl2br($this->Jobs->formatJobInfo($route)); ?>
							<?php endforeach; ?>
						</div>
						<div class="job-user"><?php echo htmlspecialchars($juinfo->name); ?></div>
						<div class="job-status"><?php echo (($job->cancel == 1) ? "Cancel request" : constant("JOB_STATUS_". $job->status)); ?></div>
						<div class="job-price"><?php echo (($job->price > 0) ? $this->Jobs->formatPrice($job->price) : "&ndash;");?></div>
						<div class="job-action"><input type="radio" value="<?php echo $this->Jobs->getID($job); ?>" name="group1"></div>
						<div class="clr"></div>
					</div>
				</div>
				<?php $c++; endforeach; ?>
			</div>
			
			<div class="pagination">
				<?php
					$url=$_SERVER['REQUEST_URI']; 
					
					$num = 0;	
					if($url ==""){
						$num = 0;				
					}
					else if(substr($url,0,15) == "sort_job_id_up_"){
						$num =1;
					}
					else if(substr($url,0,15) == "sort_job_id_dow"){
						$num =2;
					}
					else if(substr($url,0,15) == "sort_details_up"){
						$num =3;
					}
					else if(substr($url,0,15) == "sort_details_dow"){
						$num =4;
					}
					if( $oncomingPages > 6 ){
						for ($i = 0; $i < 3; $i++) {
							echo '<a href="#oncoming" onclick="loadJobPage(this, 0, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
						echo '<a  style="width:120px;background:none;margin-top:0px;" onkeypress="return runScript(event,this,0,'.$pagingId.','.$num.','.$oncomingPages.');" class="ticker'.(($i == 0) ? "-active" : "").'">.....<input style="width:70px;height:15px;margin-top:-6px" type="text" id="page0" name="page0" placeholder="Enter page" />.....</a>';	
						for ($i = $oncomingPages-3 ; $i < $oncomingPages; $i++) {
							echo '<a href="#oncoming" onclick="loadJobPage(this, 0, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
					}
					else{
						for ($i = 0; $i < $oncomingPages; $i++) {
							echo '<a href="#oncoming" onclick="loadJobPage(this, 0, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
					}
				?>
				<div class="clr"></div>
			</div>
		</div>
		
		<!--          -----------------------------------------------------------------------------          -->
		
		<h1><a id="need_quote">Awaiting Quote </a><span class="quantity"><?php echo $needquoteCount; ?></span></h1>
		<div class="job-listing">
			<div class="wrapper-world"> <!-- zaglaviq -->
				<div class="wrapper">
					<div class="job-id">Job ID <span class="uparrs"><a onclick="SortJobIdUpAwaitingQuote();"></a></span><span class="downarrs"><a onclick="SortJobIdDownAwaitingQuote();"></a></span></div>
					<div class="job-details">Details <span class="uparrs"><a onclick="SortDetailsUpAwaitingQuote();"></a></span><span class="downarrs"><a onclick="SortDetailsDownAwaitingQuote();"></a></span></div>
					<div class="job-user">User</div>
					<div class="job-action">Pick</div>
					<div class="clr"></div>
				</div>
			</div>
			
			<div class="jobsContainer">
				<?php $c=0; foreach ($needquote as $jobOrder):
					$job = $jobOrder['order'];
					$routes = $jobOrder['routes'];
					$juinfo = $jobOrder['userinfo'];
				?>
				<div class="wrapper-world job-<?php echo (($c%2 == 0) ? "odd" : "even"); if ($job->madmin == 1) { echo "  job-orange"; } ?>">
					<div class="wrapper">
						<div class="job-id"><a href="joborder/<?php echo (substr($this->Jobs->getID($job),10,3)); ?>"><?php echo $this->Jobs->getID($job); ?></a></div>
						<div class="job-details">
							<?php $c1 = 0; foreach ($routes as $route): ?>
								<?php if ($c1 > 0): ?><br /><?php else: $c1++; endif; ?>
								<?php echo nl2br($this->Jobs->formatJobInfo($route)); ?>
							<?php endforeach; ?>
						</div>
						<div class="job-user"><?php echo htmlspecialchars($juinfo->name); ?></div>
						<div class="job-action"><input type="radio" value="<?php echo $this->Jobs->getID($job); ?>"  name="group1"></div>
						<div class="clr"></div>
					</div>
				</div>
				<?php $c++; endforeach; ?>
			</div>
			
			<div class="pagination">
				<?php
					$url=$_SERVER['REQUEST_URI']; 
					
					$num = 0;	
					if($url ==""){
						$num = 0;				
					}
					else if(substr($url,0,15) == "sort_job_id_up_"){
						$num =1;
					}
					else if(substr($url,0,15) == "sort_job_id_dow"){
						$num =2;
					}
					else if(substr($url,0,15) == "sort_details_up"){
						$num =3;
					}
					else if(substr($url,0,15) == "sort_details_dow"){
						$num =4;
					}
					if( $needquotePages > 6 ){
						for ($i = 0; $i < 3; $i++) {
							echo '<a href="#need_quote" onclick="loadJobPage(this, 5, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
						echo '<a  style="width:120px;background:none;margin-top:0px;" onkeypress="return runScript(event,this,5,'.$pagingId.','.$num.','.$needquotePages.');" class="ticker'.(($i == 0) ? "-active" : "").'">.....<input style="width:70px;height:15px;margin-top:-6px" type="text" id="page5" name="page5" placeholder="Enter page"/>.....</a>';	
						for ($i = $needquotePages-3 ; $i < $needquotePages; $i++) {
							echo '<a href="#need_quote" onclick="loadJobPage(this, 5, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
					}
					else{
						for ($i = 0; $i < $needquotePages; $i++) {
							echo '<a href="#need_quote" onclick="loadJobPage(this, 5, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
					}
				?>
				<div class="clr"></div>
			</div>
		</div>
		
		<!--          -----------------------------------------------------------------------------          -->
		
		<h1><a id="need_confirm">Awaiting Confirmation </a><span class="quantity"><?php echo $needconfirmCount; ?></span></h1>
		<div class="job-listing">
			<div class="wrapper-world"> <!-- zaglaviq -->
				<div class="wrapper">
					<div class="job-id">Job ID <span class="uparrs"><a onclick="SortJobIdUpAwaitingConfirm();"></a></span><span class="downarrs"><a onclick="SortJobIdDownAwaitingConfirm();"></a></span></div>
					<div class="job-details">Details  <span class="uparrs"><a onclick="SortDetailsUpAwaitingConfirm();"></a></span><span class="downarrs"><a onclick="SortDetailsDownAwaitingConfirm();"></a></span></div>
					<div class="job-user">User</div>
					<div class="job-status">Start date</div>
					<div class="job-action">Pick</div>
					<div class="clr"></div>
				</div>
			</div>
			
			<div class="jobsContainer">
				<?php $c=0; foreach ($needconfirm as $jobOrder):
					$job = $jobOrder['order'];
					$routes = $jobOrder['routes'];
					$juinfo = $jobOrder['userinfo'];
				?>
				<div class="wrapper-world job-<?php echo (($c%2 == 0) ? "odd" : "even"); if ($job->madmin == 1) { echo "  job-orange"; } ?>">
					<div class="wrapper">
						<div class="job-id"><a href="joborder/<?php echo (substr($this->Jobs->getID($job),10,3)); ?>"><?php echo $this->Jobs->getID($job); ?></a></div>
						<div class="job-details">
							<?php $c1 = 0; foreach ($routes as $route): ?>
								<?php if ($c1 > 0): ?><br /><?php else: $c1++; endif; ?>
								<?php echo nl2br($this->Jobs->formatJobInfo($route)); ?>
							<?php endforeach; ?>
							<?php echo nl2br($this->Jobs->elapsed_date($job)); ?>
						</div>
						<div class="job-user"><?php echo htmlspecialchars($juinfo->name); ?></div>
						<div class="job-price"><?php echo $job->create_date;?></div>
						<div class="job-action"><input type="radio" value="<?php echo $this->Jobs->getID($job); ?>"  name="group1"></div>
						<div class="clr"></div>
					</div>
				</div>
				<?php $c++; endforeach; ?>
			</div>
			
			<div class="pagination">
				<?php
					$url=$_SERVER['REQUEST_URI']; 
					
					$num = 0;	
					if($url ==""){
						$num = 0;				
					}
					else if(substr($url,0,15) == "sort_job_id_up_"){
						$num =1;
					}
					else if(substr($url,0,15) == "sort_job_id_dow"){
						$num =2;
					}
					else if(substr($url,0,15) == "sort_details_up"){
						$num =3;
					}
					else if(substr($url,0,15) == "sort_details_dow"){
						$num =4;
					}
					if( $needconfirmPages > 6 ){
						for ($i = 0; $i < 3; $i++) {
							echo '<a href="#need_confirm" onclick="loadJobPage(this, 6, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
						echo '<a  style="width:120px;background:none;margin-top:0px;" onkeypress="return runScript(event,this,6,'.$pagingId.','.$num.','.$needconfirmPages.');" class="ticker'.(($i == 0) ? "-active" : "").'">.....<input style="width:70px;height:15px;margin-top:-6px" type="text" id="page6" name="page6" placeholder="Enter page" />.....</a>';	
						for ($i = $needconfirmPages-3 ; $i < $needconfirmPages; $i++) {
							echo '<a href="#need_confirm" onclick="loadJobPage(this, 6, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
					}
					else{
						for ($i = 0; $i < $needconfirmPages; $i++) {
							echo '<a href="#need_confirm" onclick="loadJobPage(this, 6, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
					}
				?>
				<div class="clr"></div>
			</div>
		</div>
		
		<!--          -----------------------------------------------------------------------------          -->
		
		<h1><a id="payment_due">Payment Due</a> <span class="quantity"><?php echo $dueCount; ?></span> <strong>Payment Overdue</strong> <span class="quantity red"><?php echo $overdueCount; ?> &ndash; <?php echo $this->Jobs->formatPrice($overduetotal); ?></span></h1>
		<div class="job-listing">
			<div class="wrapper-world"> <!-- zaglaviq -->
				<div class="wrapper">
					<div class="job-id">Job ID <span class="uparrs"><a onclick="SortJobIdUpPaymentDue();"></a></span><span class="downarrs"><a onclick="SortJobIdDownPaymentDue();"></a></span></div>
					<div class="job-details">Details  <span class="uparrs"><a onclick="SortDetailsUpPaymentDue();"></a></span><span class="downarrs"><a onclick="SortDetailsDownPaymentDue();"></a></span></div>
					<div class="job-user">User</div>
					<div class="job-date">Due date</div>
					<div class="job-price">Total</div>
					<div class="job-paid">Paid</div>
					<div class="job-left">Left to pay</div>
					<div class="job-action">Pick</div>
					<div class="clr"></div>
				</div>
			</div>
			
			<div class="jobsContainer">
				<?php $c=0; foreach ($overdue as $jobOrder):
					$job = $jobOrder['order'];
					$routes = $jobOrder['routes'];
					$juinfo = $jobOrder['userinfo'];
				?>
				<div class="wrapper-world job-<?php echo (($c%2 == 0) ? "odd" : "even"); if ($job->madmin == 1) { echo "  job-orange"; } else { echo " job-red"; } ?>">
					<div class="wrapper">
						<div class="job-id"><a href="joborder/<?php echo (substr($this->Jobs->getID($job),10,3)); ?>"><?php echo $this->Jobs->getID($job); ?></a></div>
						<div class="job-details">
							<?php $c1 = 0; foreach ($routes as $route): ?>
								<?php if ($c1 > 0): ?><br /><?php else: $c1++; endif; ?>
								<?php echo nl2br($this->Jobs->formatJobInfo($route)); ?>
							<?php endforeach; ?></div>
						<div class="job-user"><?php echo htmlspecialchars($juinfo->name); ?></div>
						<div class="job-date"><?php echo date('d M Y', strtotime($job->duedate)); ?></div>
						<div class="job-price"><?php echo $this->Jobs->formatPrice($job->price); ?></div>
						<div class="job-paid"><?php echo $this->Jobs->formatPrice($job->paid); ?></div>
						<div class="job-left"><?php echo $this->Jobs->formatPrice($job->price-$job->paid); ?></div>
						<div class="job-action"><input type="radio" value="<?php echo $this->Jobs->getID($job); ?>"  name="group1"></div>
						<div class="clr"></div>
					</div>
				</div>
				<?php $c++; endforeach; ?>
                            <?php 
                            /**
                             * phpnew comment this block because it is unknown due
                             *
				<?php 
					$c=0; 
					$due = $this->Jobs->getDuePriceList(-1, 0, 5);
					foreach ($due as $jobOrder):
						$job = $jobOrder['order'];
					$routes = $jobOrder['routes'];
				?>
				<div class="wrapper-world job-<?php echo (($c%2 == 0) ? "odd" : "even"); if ($job->madmin == 1) { echo "  job-orange"; } ?>">
					<div class="wrapper">
						<div class="job-id"><a href="joborder/<?php echo (substr($this->Jobs->getID($job),10,3)); ?>"><?php echo $this->Jobs->getID($job); ?></a></div>
						<div class="job-details">
							<?php $c1 = 0; foreach ($routes as $route): ?>
								<?php if ($c1 > 0): ?><br /><?php else: $c1++; endif; ?>
								<?php echo nl2br($this->Jobs->formatJobInfo($route)); ?>
							<?php endforeach; ?></div>
						<div class="job-date"><?php echo date('d M Y', strtotime($job->duedate)); ?></div>
						<div class="job-price"><?php echo $this->Jobs->formatPrice($job->price); ?></div>
						<div class="job-paid"><?php echo $this->Jobs->formatPrice($job->paid); ?></div>
						<div class="job-left"><?php echo $this->Jobs->formatPrice($job->price-$job->paid); ?></div>
						<div class="job-action"><?php echo $this->Jobs->showAdminActionLinks($job, "due"); ?></div>
						<div class="clr"></div>
					</div>
				</div>
				<?php $c++; endforeach; ?>
                            * 
                            */
                            ?>
			</div>
			
			<div class="pagination">
				<?php
					$url=$_SERVER['REQUEST_URI']; 
					
					$num = 0;	
					if($url ==""){
						$num = 0;				
					}
					else if(substr($url,0,15) == "sort_job_id_up_"){
						$num =1;
					}
					else if(substr($url,0,15) == "sort_job_id_dow"){
						$num =2;
					}
					else if(substr($url,0,15) == "sort_details_up"){
						$num =3;
					}
					else if(substr($url,0,15) == "sort_details_dow"){
						$num =4;
					}
					if( $dueOverduePages > 6 ){
						for ($i = 0; $i < 3; $i++) {
							echo '<a href="#payment_due" onclick="loadJobPage(this, 2, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
						echo '<a  style="width:120px;background:none;margin-top:0px;" onkeypress="return runScript(event,this,2,'.$pagingId.','.$num.','.$dueOverduePages.');" class="ticker'.(($i == 0) ? "-active" : "").'">.....<input style="width:70px;height:15px;margin-top:-6px" type="text" id="page2" name="page2" placeholder="Enter page" />.....</a>';	
						for ($i = $dueOverduePages-3 ; $i < $dueOverduePages; $i++) {
							echo '<a href="#payment_due" onclick="loadJobPage(this, 2, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
					}
					else{
						for ($i = 0; $i < $dueOverduePages; $i++) {
							echo '<a href="#payment_due" onclick="loadJobPage(this, 2, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
					}
				?>
				<div class="clr"></div>
			</div>
		</div>
		
		<!--          -----------------------------------------------------------------------------          -->
		
		<h1><a id="complete">Completed</a> <span class="quantity"><?php echo $completedCount; ?></span></h1>
		<div class="job-listing">
			<div class="wrapper-world"> <!-- zaglaviq -->
				<div class="wrapper">
					<div class="job-id">Job ID <span class="uparrs"><a onclick="SortJobIdUpComplete();"></a></span><span class="downarrs"><a onclick="SortJobIdDownComplete();"></a></span></div>
					<div class="job-details">Details  <span class="uparrs"><a onclick="SortDetailsUpComplete();"></a></span><span class="downarrs"><a onclick="SortDetailsDownComplete();"></a></span></div>
					<div class="job-user">User</div>
					<div class="job-date">Completed</div>
					<div class="job-price">Price</div>
					<div class="job-action">Pick</div>
					<div class="clr"></div>
				</div>
			</div>
			
			<div class="jobsContainer">
				<?php $c=0; foreach ($completed as $jobOrder):
					$job = $jobOrder['order'];
					$routes = $jobOrder['routes'];
					$juinfo = $jobOrder['userinfo'];
				?>
				<div class="wrapper-world job-<?php echo (($c%2 == 0) ? "odd" : "even"); if ($job->madmin == 1) { echo "  job-orange"; } ?>">
					<div class="wrapper">
						<div class="job-id"><a href="joborder/<?php echo (substr($this->Jobs->getID($job),10,3)); ?>"><?php echo $this->Jobs->getID($job); ?></a></div>
						<div class="job-details">
							<?php $c1 = 0; foreach ($routes as $route): ?>
								<?php if ($c1 > 0): ?><br /><?php else: $c1++; endif; ?>
								<?php echo nl2br($this->Jobs->formatJobInfo($route)); ?>
							<?php endforeach; ?>
						</div>
						<div class="job-user"><?php echo htmlspecialchars($juinfo->name); ?></div>
						<div class="job-date"><?php echo $job->date; ?></div>
						<div class="job-price"><?php echo (($job->price > 0) ? $this->Jobs->formatPrice($job->price) : "&ndash;");?></div>
						<div class="job-action"><input type="radio" value="<?php echo $this->Jobs->getID($job); ?>"  name="group1"></div>
						<div class="clr"></div>
					</div>
				</div>
				<?php $c++; endforeach; ?>
			</div>
			
			<div class="pagination">
				<?php
					$url=$_SERVER['REQUEST_URI']; 
					
					$num = 0;	
					if($url ==""){
						$num = 0;				
					}
					else if(substr($url,0,15) == "sort_job_id_up_"){
						$num =1;
					}
					else if(substr($url,0,15) == "sort_job_id_dow"){
						$num =2;
					}
					else if(substr($url,0,15) == "sort_details_up"){
						$num =3;
					}
					else if(substr($url,0,15) == "sort_details_dow"){
						$num =4;
					}
					if( $completedPages > 6 ){
						for ($i = 0; $i < 3; $i++) {
							echo '<a href="#complete" onclick="loadJobPage(this, 3, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
						echo '<a  style="width:120px;background:none;margin-top:0px;" onkeypress="return runScript(event,this,3,'.$pagingId.','.$num.','.$completedPages.');" class="ticker'.(($i == 0) ? "-active" : "").'">.....<input style="width:70px;height:15px;margin-top:-6px" type="text" id="page3" name="page3" placeholder="Enter page" />.....</a>';	
						for ($i = $completedPages-3 ; $i < $completedPages; $i++) {
							echo '<a href="#complete" onclick="loadJobPage(this, 3, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
					}
					else{
						for ($i = 0; $i < $completedPages; $i++) {
							echo '<a href="#complete" onclick="loadJobPage(this, 3, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
					}
				?>
				<div class="clr"></div>
			</div>
		</div>
		
		<h1><a id="cancel">Cancelled </a><span class="quantity"><?php echo $cancelledCount; ?></span></h1>
		<div class="job-listing">
			<div class="wrapper-world"> <!-- zaglaviq -->
				<div class="wrapper">
					<div class="job-id">Job ID <span class="uparrs"><a onclick="SortJobIdUpCancel();"></a></span><span class="downarrs"><a onclick="SortJobIdDownCancel();"></a></span></div>
					<div class="job-details">Details  <span class="uparrs"><a onclick="SortDetailsUpCancel();"></a></span><span class="downarrs"><a onclick="SortDetailsDownCancel();"></a></span></div>
					<div class="job-user">User</div>
					<div class="job-status">Status</div>
					<div class="job-price">Price</div>
					<div class="job-action">Pick</div>
					<div class="clr"></div>
				</div>
			</div>
			
			<div class="jobsContainer">
				<?php $c=0; foreach ($cancelled as $jobOrder):
					$job = $jobOrder['order'];
					$routes = $jobOrder['routes'];
					$juinfo = $jobOrder['userinfo'];
				?>
				<div class="wrapper-world job-<?php echo (($c%2 == 0) ? "odd" : "even"); ?>">
					<div class="wrapper">
						<div class="job-id"><a href="joborder/<?php echo (substr($this->Jobs->getID($job),10,3)); ?>"><?php echo $this->Jobs->getID($job); ?></a></div>
						<div class="job-details">
							<?php $c1 = 0; foreach ($routes as $route): ?>
								<?php if ($c1 > 0): ?><br /><?php else: $c1++; endif; ?>
								<?php echo nl2br($this->Jobs->formatJobInfo($route)); ?>
							<?php endforeach; ?>
						</div>
						<div class="job-user"><?php echo htmlspecialchars($juinfo->name); ?></div>
						<div class="job-status"><?php echo constant("JOB_STATUS_". $job->status); ?></div>
						<div class="job-price"><?php echo (($job->price > 0) ? $this->Jobs->formatPrice($job->price) : "&ndash;");?></div>
						<div class="job-action"><input type="radio" value="<?php echo $this->Jobs->getID($job); ?>"  name="group1"></div>
						<div class="clr"></div>
					</div>
				</div>
				<?php $c++; endforeach; ?>
			</div>
			
			<div class="pagination">
				<?php
					$url=$_SERVER['REQUEST_URI']; 
					
					$num = 0;	
					if($url ==""){
						$num = 0;				
					}
					else if(substr($url,0,15) == "sort_job_id_up_"){
						$num =1;
					}
					else if(substr($url,0,15) == "sort_job_id_dow"){
						$num =2;
					}
					else if(substr($url,0,15) == "sort_details_up"){
						$num =3;
					}
					else if(substr($url,0,15) == "sort_details_dow"){
						$num =4;
					}
					if( $cancelledPages > 6 ){
						for ($i = 0; $i < 3; $i++) {
							echo '<a href="#cancel" onclick="loadJobPage(this, 4, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
						echo '<a style="width:120px;background:none;margin-top:0px;" onkeypress="runScript(event,this,4,'.$pagingId.','.$num.','.$cancelledPages.');" class="ticker'.(($i == 0) ? "-active" : "").'">.....<input style="width:70px;height:15px;margin-top:-6px" type="text" id="page4" name="page4" placeholder="Enter page" />.....</a>';	
						for ($i = $cancelledPages-3 ; $i < $cancelledPages; $i++) {
							echo '<a href="#cancel" onclick="loadJobPage(this, 4, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
					}
					else{
						for ($i = 0; $i < $cancelledPages; $i++) {
							echo '<a href="#cancel" onclick="loadJobPage(this, 4, '.$i.', '.$pagingId.','.$num.');" class="ticker'.(($i == 0) ? "-active" : "").'">'.($i+1).'</a>';
						}
					}
				?>
				
				<div class="clr"></div>
			</div>
		</div>
	</div> <!-- end of wrapper-world and .content -->
	
	
		
	<div class="wrapper-world footer-top">
		<div class="wrapper"></div>	
	</div>
	
	<?php $this->load->view('footer'); ?>

</body>
</html>
